package ru.study.thinkin.chapter9;

class PercussionImp implements InstrumentInt {

	public void play(Note n) {
		System.out.println(this + "play()" + n);
	}

	@Override
	public String toString() {
		return "Percussion";
	}

	public void adjust() {

	}
}
class WindImp implements InstrumentInt {

	public void play(Note n) {
		System.out.println(this + " play()" + n);
	}

	public String toString() {
		return "Wind";
	}

	public void adjust() {

	}
	public WindImp whois(Object o) {
		return (WindImp) o;
	}
}

class Brass extends WindImp {

	@Override
	public void play(Note n) {
		System.out.println(this+" play()"+n);
	}

	@Override
	public String toString() {
		return "Brass";
	}

	@Override
	public void adjust() {
		super.adjust();
	}
	
	@Override
	public WindImp whois(Object o) {
		//return "It's "+o.toString();
		return (Brass) o;
	}
}

public class Music5 {
	static void tune(InstrumentInt i) {
		i.play(Note.MIDDLE_C);
	}
	static void tuneAll(InstrumentInt[] e) {
		for(InstrumentInt i : e) {
			System.out.print("val="+i.VALUE+" ");
			tune(i);
			if (i instanceof WindImp ) {
				String o = "234";
				System.out.println(((WindImp) i).whois(o));
			}
		}
	}
	public static void main(String[] args) {
		InstrumentInt[] orchestra = new InstrumentInt[]{new WindImp(),new Brass(),new PercussionImp()};
		tuneAll(orchestra);

	}

}
